using System.Collections;
using Holoville.HOTween;
using UnityEngine;

public class EnemyBehavior : Humanoid, ILogicAssigner
{
	public LayerMask collisionLayer;

	public int skinNumber;

	public bool isPolice;

	public bool isPussy;

	public bool isAggressive;

	public int accuracy;

	public GameObject myCollidePoint;

	private float timeLastPlayDamage;

	private float timeDelayBetweenPlayDamage = 0.3f;

	public int MAX_DISTANCE_FROM_PLAYER = 70;

	public float normalSpeed;

	public float chaisingSpeed;

	public float rotSpeed;

	public EnemyState currentState;

	public EnemyState previousState;

	public int reward;

	public GameObject bloodParticle;

	public GameObject wallParticle;

	public GameObject electroshockParticle;

	public GameObject hole;

	public GameObject playerTarget;

	public GameObject weaponHolder;

	public bool carDamage;

	public bool isShocked;

	public new Material mainMaterial;

	public bool isSlave;

	public float healthMultiplier = 1f;

	public string poolName;

	public SectorMobManager sectorMobManager;

	public EnemyAreaBehavior enemyAreaBehavior;

	public MoneyType RewardIn;

	public int moneyReward;

	public int expirienceReward;

	public bool waitRespawn;

	public BehaviorModel behaviorModel;

	public EnemyType enemyType;

	public float reload;

	public float dPS;

	public float spread = 1f;

	[HideInInspector]
	public CapsuleCollider capsCollider;

	[HideInInspector]
	public BaseWeapon weaponScript;

	public GameObject enemyWeapon;

	public string weaponKey;

	[HideInInspector]
	public float scale;

	[HideInInspector]
	public Texture skinTexture;

	public AnimatorOverrideController animatorOverride;

	public int itemChanceDrop;

	public int ammoDropCh;

	public int healthDropCh;

	public int jetpackDropCh;

	private bool isFollowing;

	private int bulletCount;

	private float updateTimer;

	public SkinnedMeshRenderer meshInCam;

	private GameObject currentTarget;

	private bool playerHasDead;

	private bool isShooting;

	private PlayerBehavior pBehavior;

	private new PlayerSounds soundsManager;

	private IEnumerator _initWeapon;

	public new NJGMapItem iconMiniMap;

	public NJGMapItem iconAgroZoneMiniMap;

	private Vector3 initPosition;

	private Quaternion initRotation;

	private LogicController _logicController;

	private IEnumerator curEnumerator;

	private bool lastShoot;

	private float oldRadius;

	private float oldHeight;

	public int percentForDropMoney;

	public int percentForDropExperience;

	public bool ShowInCam
	{
		get
		{
			if (meshInCam == null)
			{
				return true;
			}
			return meshInCam.isVisible;
		}
	}

	public LogicController logicController
	{
		get
		{
			if (_logicController == null)
			{
				_logicController = new EnemyLogicController();
			}
			return _logicController;
		}
	}

	public override void Awake()
	{
		base.Awake();
		ownerViewId = -100;
		mobNavigationController = GetComponent<MobNavigationController>();
		mobNavigationController = GetComponent<MobNavigationController>();
		enemyAreaBehavior = GetComponent<EnemyAreaBehavior>();
		capsCollider = GetComponent<CapsuleCollider>();
		mecanimWrapper.isMob = true;
		if (meshInCam != null && GameController.instance != null)
		{
			Material material = new Material(GameController.instance.defaultShaderForPlayer);
			material.mainTexture = meshInCam.material.mainTexture;
			meshInCam.material = material;
			meshInCam.material.SetColor("_Color", Color.red);
			meshInCam.material.SetFloat("_Alpha", 1f);
		}
		HOTween.Init();
		CreateMaterial();
		logicController.AddAssigner(this);
	}

	public void MobSpawned(Vector3 position, Quaternion rotation, MobParameters element, int mobLevel, SectorMobManager sector)
	{
		initPosition = position;
		initRotation = rotation;
		base.transform.position = position;
		base.transform.rotation = rotation;
		skinNumber = element.skinList[Random.Range(0, element.skinList.Count)].skinNumbers;
		sectorMobManager = sector;
		dPS = element.levelsList[mobLevel].dPS;
		maxHealth = element.levelsList[mobLevel].health;
		accuracy = element.levelsList[mobLevel].accuracy;
		weaponKey = element.levelsList[mobLevel].weaponKey;
		enemyAreaBehavior.aggressiveDistance = element.levelsList[mobLevel].atackDistance;
		enemyAreaBehavior.chasingDistance = element.levelsList[mobLevel].chasingDistance;
		scale = element.scale;
		itemChanceDrop = element.itemChanceDrop;
		ammoDropCh = element.ammoDropCh;
		healthDropCh = element.healthDropCh;
		jetpackDropCh = element.jetpackDropCh;
		chaisingSpeed = element.levelsList[mobLevel].chasingSpeed;
		normalSpeed = element.levelsList[mobLevel].normalSpeed;
		RewardIn = element.RewardIn;
		moneyReward = element.moneyReward;
		expirienceReward = element.expirienceReward;
		animatorOverride = element.animatorOverride;
		percentForDropExperience = element.percentForDropExperience;
		percentForDropMoney = element.percentForDropMoney;
		enemyType = element.enemyType;
		poolName = element.poolName;
		isSlave = element.isSlave;
		carDamage = false;
		capsCollider.enabled = true;
		timeLastPlayDamage = Time.timeSinceLevelLoad;
		base.transform.localScale = Vector3.one * scale;
		if (element.levelsList[mobLevel].normalSpeed != 0f)
		{
			mobNavigationController.walkSpeed = element.levelsList[mobLevel].normalSpeed;
		}
		else
		{
			mobNavigationController.walkSpeed = 1.5f;
		}
		if (element.levelsList[mobLevel].chasingSpeed != 0f)
		{
			mobNavigationController.runSpeed = element.levelsList[mobLevel].chasingSpeed;
		}
		else
		{
			mobNavigationController.runSpeed = 3.5f;
		}
		mobNavigationController.walkSpeed *= Random.Range(0.8f, 1.2f);
		mobNavigationController.runSpeed *= Random.Range(0.8f, 1.2f);
		initEnemy();
		if (_initWeapon != null)
		{
			StopCoroutine(_initWeapon);
		}
		_initWeapon = initWeapon();
		StartCoroutine(_initWeapon);
		SwitchEnemyState(EnemyState.Passive);
		StartCoroutine(MyUpdate());
		SetupMiniMapIcons();
		FullHealthAndArmor();
		AppearFromInvisible();
	}

	public override void Init()
	{
		base.Init();
		InitEvents(new string[1] { "MobPlased" });
	}

	public void StartMechanim(float speed)
	{
		mecanimWrapper.Idle(false);
		mecanimWrapper.StartCheck(base.mainRender);
		mecanimWrapper.currentVelocuty = speed / mobNavigationController.runSpeed;
	}

	public void StopMechanim()
	{
		mecanimWrapper.Idle(true);
		mecanimWrapper.currentVelocuty = 0f;
	}

	public void OnLogicEvent(int name, params object[] args)
	{
		switch ((mobLogicEvent)name)
		{
		case mobLogicEvent.StopWalk:
			StopMechanim();
			break;
		case mobLogicEvent.StartWalk:
			StartMechanim(mobNavigationController.walkSpeed);
			break;
		case mobLogicEvent.StartRun:
			mecanimWrapper.Idle(false);
			StartMechanim(mobNavigationController.runSpeed);
			break;
		case mobLogicEvent.StartIdle:
			StopMechanim();
			break;
		case mobLogicEvent.Enable:
			base.gameObject.SetActive(true);
			break;
		case mobLogicEvent.Disable:
			StopMechanim();
			break;
		case mobLogicEvent.PlaceMob:
			break;
		case mobLogicEvent.GoToNearestWalkPoint:
			break;
		case mobLogicEvent.GoToNextWalkPoint:
			break;
		case mobLogicEvent.SendEnableObstacle:
			break;
		case mobLogicEvent.WarpToRandomSpawnPoint:
			break;
		case mobLogicEvent.FindNewPath:
			break;
		case mobLogicEvent.ShowGun:
		case mobLogicEvent.GoToTarget:
		case mobLogicEvent.CalculateNewPath:
		case mobLogicEvent.GoToRandomPoint:
		case mobLogicEvent.ObstaclePlayer:
		case mobLogicEvent.ObstacleMob:
		case mobLogicEvent.ObstacleCar:
		case mobLogicEvent.TryfindNewPathForCurentPoint:
			break;
		}
	}

	public void SendToLogic(int name, params object[] args)
	{
		logicController.OnAssignerEvent(name, args);
	}

	public override void OnEnable()
	{
		PlayerBehavior.OnDead += OnPlayerDead;
	}

	public override void OnDisable()
	{
		ResetEnemyParameters();
		PlayerBehavior.OnDead -= OnPlayerDead;
	}

	public void ResetEnemyParameters()
	{
		SendToLogic(11);
		StopCoroutine(reset());
		if (_initWeapon != null)
		{
			StopCoroutine(_initWeapon);
		}
		_initWeapon = null;
		StopAllCoroutines();
		enemyAreaBehavior.StopAllCoroutines();
		Object.Destroy(enemyWeapon);
		enemyAreaBehavior.aggressiveDistance = 0f;
		dPS = 0f;
		weaponScript = null;
		ResetLastDamageInfo(WeaponType.Non, WeaponTypeSpecific.Non, 0, -1f, 0f, false, false, false, false, false, false);
	}

	private void OnPlayerDead()
	{
		if (base.gameObject.activeSelf)
		{
			PoliceManager.Instance.StopChasing();
			CheckPlayerDeath();
		}
	}

	private IEnumerator initWeapon()
	{
		if (enemyWeapon != null)
		{
			Object.Destroy(enemyWeapon);
		}
		if (weaponHolder != null)
		{
			if (string.IsNullOrEmpty(weaponKey))
			{
				weaponKey = "eagl";
			}
			ResourceRequest weapon = Resources.LoadAsync("Weapons/" + weaponKey);
			yield return weapon;
			enemyWeapon = (GameObject)Object.Instantiate(weapon.asset as GameObject, weaponHolder.transform.position, weaponHolder.transform.rotation);
			enemyWeapon.name = weaponKey + " (inst)";
			if (enemyWeapon != null)
			{
				enemyWeapon.transform.localScale = Vector3.one * scale;
				weaponScript = enemyWeapon.GetComponent<BaseWeapon>();
				weaponScript.Init(collisionLayer, weaponHolder.transform, weaponHolder.transform, mainCollider, true);
				weaponScript.isMobWeapon = true;
				weaponScript.ammo = 99999;
				weaponScript.strength = 1f;
				weaponScript.chargerAmmo = weaponScript.maxChargerAmmo;
				if (weaponScript.weaponMecanimWrapper != null)
				{
					weaponScript.weaponMecanimWrapper.Init(mecanimWrapper, weaponScript.reloadTime, weaponScript.timeBetweenShots);
				}
			}
			toggleGun(isAggressive);
		}
		if (weaponScript != null)
		{
			updateTimer = weaponScript.timeBetweenShots;
			reload = ((weaponScript.reloadTime != 0f && weaponScript.maxChargerAmmo != 0) ? (weaponScript.reloadTime / (float)weaponScript.maxChargerAmmo) : 0f);
			weaponScript.damage = Mathf.Max(1f, dPS * (updateTimer + reload)) / (float)weaponScript.bulletInOneShoot;
			enemyAreaBehavior.aggressiveDistance = weaponScript.maxDistance / 5f;
			if (enemyAreaBehavior.aggressiveDistance < 3f)
			{
				enemyAreaBehavior.aggressiveDistance = 3f;
			}
		}
		else
		{
			updateTimer = 0.5f;
		}
		yield return new WaitForSeconds(0.5f);
		SendToLogic(0, initPosition, initRotation, TutorialManager.TuturialWorking());
		yield return new WaitForSeconds(0.5f);
		RiseEvent(this, "MobPlased");
	}

	public void SwitchEnemyBehaviourModel(BehaviorModel model)
	{
		switch (model)
		{
		case BehaviorModel.Aggressive:
			isAggressive = true;
			isPussy = false;
			isPolice = false;
			break;
		case BehaviorModel.Passive:
			if (PoliceManager.Instance != null && PoliceManager.Instance.currentWarningLevel != WarningLevel.Chasing)
			{
				isAggressive = false;
			}
			isPussy = false;
			isPolice = false;
			break;
		case BehaviorModel.Civilian:
			isAggressive = false;
			isPussy = true;
			isPolice = false;
			break;
		case BehaviorModel.Police:
			if (PoliceManager.Instance != null && PoliceManager.Instance.currentWarningLevel != WarningLevel.Chasing)
			{
				isAggressive = false;
			}
			isPussy = false;
			isPolice = true;
			break;
		}
	}

	private void SetupMiniMapIcons()
	{
		if (!(iconMiniMap == null))
		{
			if (enemyType == EnemyType.Zombie)
			{
				iconMiniMap.enabled = false;
			}
			iconMiniMap.enabled = behaviorModel == BehaviorModel.Aggressive || behaviorModel == BehaviorModel.Police;
			if (behaviorModel == BehaviorModel.Aggressive)
			{
				iconMiniMap.type = 17;
			}
			if (behaviorModel == BehaviorModel.Police)
			{
				iconMiniMap.type = 16;
			}
		}
	}

	public void ShowAgroZone(bool show)
	{
		iconAgroZoneMiniMap.enabled = show;
	}

	private void initEnemy()
	{
		if ((bool)weaponEffectWatcher)
		{
			weaponEffectWatcher.StopAllEffectsImmediate();
		}
		SetComponentCollider(true);
		SwitchEnemyBehaviourModel(behaviorModel);
		if (prefabPlayer == null)
		{
			prefabPlayer = base.transform.Find("player_mecanim").gameObject;
		}
		initSkin(skinNumber);
		waitRespawn = false;
		isDead = false;
		if ((bool)sectorMobManager)
		{
			mobNavigationController.sectorPoints = sectorMobManager.sectorPoints;
		}
		currentState = EnemyState.Passive;
		pBehavior = GameController.instance.playerScript;
		if (enemyAreaBehavior.chasingDistance.Equals(0f))
		{
			enemyAreaBehavior.chasingDistance = 50f;
		}
		if (PoliceManager.Instance != null && PoliceManager.Instance.currentWarningLevel == WarningLevel.Chasing)
		{
			Invoke("GiveDmgs", 0.5f);
		}
	}

	public void GiveDmgs()
	{
		GetDamage(0, 0);
	}

	private IEnumerator MyUpdate()
	{
		while (true)
		{
			if (!carDamage)
			{
				updateBehavior();
				updateTarget();
			}
			yield return new WaitForSeconds(updateTimer);
		}
	}

	private void updateTarget()
	{
		if (GameController.instance.carScript == null)
		{
			if (!pBehavior.isDead)
			{
				playerTarget = GameController.instance.myPlayer;
			}
		}
		else if (GameController.instance.carScript != null)
		{
			playerTarget = GameController.instance.carScript.gameObject;
		}
		if (playerTarget != null && currentState != EnemyState.Passive && Vector3.Distance(base.transform.position, playerTarget.transform.position) < enemyAreaBehavior.aggressiveDistance)
		{
			SendToLogic(13, GameController.instance.myPlayer.transform, this);
		}
	}

	private void Passive()
	{
		if (previousState != currentState)
		{
			CheckPlayerDeath();
		}
		if (playerHasDead != pBehavior.isDead)
		{
			playerHasDead = pBehavior.isDead;
		}
	}

	public void lowDamageCar(int damag)
	{
		if (!carDamage)
		{
			carDamage = true;
			canMove = false;
			if (GameController.instance.playerScript.inCar)
			{
				GameController.instance.playerScript.SetPlayerLastDamageInfo(GetComponent<Mortal>(), false);
				lastDamageInfo.weaponType = WeaponType.Car;
				lastDamageInfo.weaponTypeSpecific = WeaponTypeSpecific.Non;
			}
			GetDamage(damag, 2);
			mecanimWrapper.DropDown();
			mecanimWrapper.HoldShoot(false);
			if (!isDead)
			{
				Invoke("wakeUpAfterCar", 3f);
			}
			StartFlickerWhileGettingUp(mainMaterial);
		}
	}

	public void highDamageCar(int damag)
	{
		if (!carDamage)
		{
			carDamage = true;
			canMove = false;
			if (GameController.instance.playerScript.inCar)
			{
				GameController.instance.playerScript.SetPlayerLastDamageInfo(GetComponent<Mortal>(), false);
				lastDamageInfo.weaponType = WeaponType.Car;
				lastDamageInfo.weaponTypeSpecific = WeaponTypeSpecific.Non;
			}
			mecanimWrapper.HoldShoot(false);
			GetDamage(damag, 2);
			mecanimWrapper.DropDownMajor();
			if (!isDead)
			{
				Invoke("wakeUpAfterCar", 3f);
			}
			StartFlickerWhileGettingUp(mainMaterial);
		}
	}

	private void wakeUpAfterCar()
	{
		if (carDamage)
		{
			mecanimWrapper.StandUp();
			if (!isDead)
			{
				Invoke("showOurGun", 1.5f);
			}
		}
	}

	private void showOurGun()
	{
		StoptFlickerWhileGettingUp(mainMaterial);
		carDamage = false;
		if (isAggressive)
		{
			toggleGun(true);
		}
		canMove = true;
	}

	public void toggleGun(bool show)
	{
		if (!(weaponScript != null) || !(enemyWeapon != null))
		{
			return;
		}
		if (show)
		{
			if (!carDamage)
			{
				if (curEnumerator != null)
				{
					StopCoroutine(curEnumerator);
					curEnumerator = null;
				}
				curEnumerator = ShowGun();
				StartCoroutine(curEnumerator);
			}
		}
		else
		{
			if (curEnumerator != null)
			{
				StopCoroutine(curEnumerator);
				curEnumerator = null;
			}
			curEnumerator = HideGun();
			StartCoroutine(curEnumerator);
		}
	}

	private IEnumerator ShowGun()
	{
		yield return new WaitForSeconds(Random.Range(0f, 1.5f));
		enemyWeapon.SetActive(true);
		if (weaponScript.weaponMecanimWrapper.overrideController != null && !isDead)
		{
			mecanimWrapper.SetWeapon(weaponScript.weaponMecanimWrapper.overrideController, weaponScript.reloadTime, weaponScript.timeBetweenShots, weaponScript.weaponMecanimWrapper.pullable);
		}
	}

	private IEnumerator HideGun()
	{
		yield return new WaitForSeconds(Random.Range(0f, 1.5f));
		if (enemyWeapon != null)
		{
			enemyWeapon.SetActive(false);
		}
		if (animatorOverride != null)
		{
			mecanimWrapper.SetWeapon(animatorOverride, 1f, 1f);
		}
	}

	public void SwitchEnemyState(EnemyState state)
	{
		currentState = state;
		switch (currentState)
		{
		case EnemyState.Chasing:
			break;
		case EnemyState.Passive:
			SendToLogic(18);
			break;
		case EnemyState.Escaping:
			break;
		}
	}

	private void Aggressive()
	{
		if (!(playerTarget != null))
		{
			return;
		}
		if (isPlayerVisible() && !carDamage)
		{
			if (canMove)
			{
				rotateToTarget(playerTarget.transform.position);
			}
			if (canShoot)
			{
				SendToLogic(13, GameController.instance.myPlayer.transform, this);
			}
			if (weaponScript != null && weaponScript.canShoot && canShoot)
			{
				if (isPolice)
				{
					PoliceManager.Instance.SwitchWarningLevel(WarningLevel.Chasing);
				}
				weaponScript.maxSpreadWeapon = spread;
				weaponScript.spreadWeapon = spread;
				weaponScript.Shoot(playerTarget.transform.position + Vector3.up);
				weaponScript.ammo += ((!weaponScript.useAmmoForMultiplerShoot) ? 1 : weaponScript.bulletInOneShoot);
				mecanimWrapper.HoldShoot(true);
				lastShoot = true;
			}
		}
		else if (!GameController.instance.playerScript.isDead)
		{
			currentState = EnemyState.Chasing;
			weaponScript.StopShoot();
			mecanimWrapper.HoldShoot(false);
			lastShoot = false;
		}
	}

	private bool isPlayerVisible()
	{
		if (playerTarget != null)
		{
			if (GameController.instance.carScript != null)
			{
				return true;
			}
			Ray ray = new Ray(base.transform.position + new Vector3(0f, 1f, 0f), playerTarget.transform.position - base.transform.position);
			if (BCWDebug.isDebugBuild)
			{
				Debug.DrawRay(base.transform.position, playerTarget.transform.position - base.transform.position);
			}
			RaycastHit hitInfo;
			if (Physics.Raycast(ray, out hitInfo, float.PositiveInfinity, collisionLayer) && hitInfo.collider.transform.root.tag == "Player")
			{
				return true;
			}
		}
		return false;
	}

	public void CheckPlayerDeath()
	{
		SwitchEnemyBehaviourModel(behaviorModel);
		currentState = EnemyState.Passive;
		SwitchEnemyState(EnemyState.Passive);
		playerTarget = null;
	}

	private void Chase()
	{
		SendToLogic(16, GameController.instance.myPlayer.transform, this);
	}

	private void updateBehavior()
	{
		if (GameController.instance == null || GameController.instance.playerScript == null || !base.gameObject.activeSelf || isDead || isShocked)
		{
			return;
		}
		switch (currentState)
		{
		case EnemyState.Passive:
			if (lastShoot)
			{
				mecanimWrapper.HoldShoot(false);
				lastShoot = false;
			}
			Passive();
			break;
		case EnemyState.Aggressive:
			if (weaponScript != null)
			{
				Aggressive();
			}
			break;
		case EnemyState.Chasing:
			if (lastShoot)
			{
				mecanimWrapper.HoldShoot(false);
				lastShoot = false;
			}
			Chase();
			break;
		case EnemyState.Escaping:
			Chase();
			if (lastShoot)
			{
				mecanimWrapper.HoldShoot(false);
				lastShoot = false;
			}
			break;
		}
		previousState = currentState;
	}

	private void initSkin(int skinNumber)
	{
		if (skinNumber != -1)
		{
			settings.getTekSkin(this, skinNumber);
		}
	}

	public void SetSkin(Texture2D newSkin)
	{
		if (prefabPlayer == null)
		{
			prefabPlayer = base.transform.Find("player_mecanim").gameObject;
		}
		GameController.SetMaterialAndTextureForEnemy(base.gameObject, newSkin, this);
	}

	public override void GetDamage(int damage, int damageType, int iKillerId, Vector3 positionKiller, Vector3? hitPoint = null)
	{
		if (!isDead)
		{
			if (damage != 0 && settings.learningCompleted && behaviorModel != 0)
			{
				PoliceManager.Instance.SwitchWarningLevel(WarningLevel.Chasing);
			}
			if (damage > 0 && isPussy)
			{
				for (int i = 0; i < MobSpawnController.instance.MobsList.Count; i++)
				{
					MobSpawnController.instance.MobsList[i].GetDamage(0, 0);
				}
			}
			if (damage < 0)
			{
				return;
			}
			if (!MobSpawnController.instance.canSpawnAggressiveMobs)
			{
				MobSpawnController.instance.StartSpawnAggressiveMobs();
			}
			if (VolumeController.IsSoundEnable && damage > 0 && Time.timeSinceLevelLoad - timeLastPlayDamage > timeDelayBetweenPlayDamage)
			{
				timeLastPlayDamage = Time.timeSinceLevelLoad;
				if (soundsManager != null)
				{
					soundsManager.Damage();
				}
			}
			if (!isAggressive && !isPussy && GameController.instance.playerScript.CanBeAttacked())
			{
				isAggressive = true;
				toggleGun(true);
			}
			if (isPussy)
			{
				SwitchEnemyState(EnemyState.Escaping);
			}
		}
		base.GetDamage(damage, damageType, iKillerId, positionKiller, (Vector3?)null);
	}

	private void SetComponentCollider(bool active)
	{
		Collider[] componentsInChildren = GetComponentsInChildren<Collider>();
		foreach (Collider collider in componentsInChildren)
		{
			collider.enabled = active;
		}
		if (!active)
		{
		}
	}

	public override void Kill(int iKillerId)
	{
		SendToLogic(17);
		SetComponentCollider(false);
		if ((bool)GameplayEventsManager.instance)
		{
			GameplayEventsManager.instance.NewOfflineKill(currentState, behaviorModel, enemyType, lastDamageInfo);
		}
		base.Kill(iKillerId);
		if (prefabPlayer == null)
		{
			prefabPlayer = base.transform.Find("player_mecanim").gameObject;
		}
		if (enemyWeapon != null)
		{
			enemyWeapon.SetActive(false);
		}
		if (settings.learningCompleted && base.gameObject.name != "enemyDog(Clone)")
		{
			settings.updateKolKill(settings.tekKolKillPVE + 1);
			settings.WeekCountKillPVE++;
			if (RewardIn == MoneyType.Cash)
			{
				bonuseManager.thisScript.CreateBonuseWithId(idBonuse.Money, false, base.transform.position, 3, 0.1f, percentForDropMoney, moneyReward, moneyReward);
			}
			else if (RewardIn != MoneyType.Gold)
			{
			}
			bonuseManager.thisScript.CreateBonuseWithId(idBonuse.Star, false, base.transform.position, 3, 0.1f, percentForDropExperience, expirienceReward, expirienceReward);
			bonuseManager.thisScript.DropBonuseTypeFromMob(typeGroupBonuse.Item, false, base.transform.position, 3, 0.1f, itemChanceDrop, 1, 1, healthDropCh, ammoDropCh, jetpackDropCh);
		}
		capsCollider.enabled = false;
		ManagerMissions.OnKillMob(this);
		GameController.instance.offlineKolKill++;
		StartCoroutine(reset());
	}

	private IEnumerator reset()
	{
		yield return StartCoroutine(BCWUtils.WaitForRealSeconds(3f));
		SendToLogic(19);
		waitRespawn = true;
		carDamage = false;
	}

	public void Reload()
	{
		if (weaponScript != null)
		{
			weaponScript.weaponMecanimWrapper.Reload();
		}
	}

	public void rotateToTarget(Vector3 target)
	{
		target.y = base.transform.position.y;
		Quaternion b = Quaternion.LookRotation(target - base.transform.position);
		base.transform.rotation = Quaternion.Slerp(base.transform.rotation, b, rotSpeed * Time.deltaTime);
	}

	private bool checkAccuracy()
	{
		return Random.Range(0, 100) <= accuracy;
	}

	public void ChangeTriggerColliderEnemy()
	{
		CancelInvoke("VklIsTrigColliderEnemy");
		capsCollider.isTrigger = false;
		Invoke("VklIsTrigColliderEnemy", 0.05f);
	}

	private void VklIsTrigColliderEnemy()
	{
		capsCollider.isTrigger = true;
	}
}
